package cn.net.xinyi.xs.service.hr;

import java.util.List;

import cn.net.xinyi.xs.dao.hr.UserDao;
import cn.net.xinyi.xs.model.hr.User;
import cn.net.xinyi.xs.service.Manager;
import cn.net.xinyi.xs.service.UserExistsException;
import cn.net.xinyi.xs.service.XinYiException;

/**
 * Business Service Interface to handle communication between web and
 * persistence layer.
 * 
 * @author <a href="mailto:caihualin2009@gmail.com">Cai Hua</a>
 */
public interface UserManager extends Manager {

	/**
	 * Convenience method for testing - allows you to mock the DAO and set it on
	 * an interface.
	 * 
	 * @param userDao
	 *            the UserDao implementation to use
	 */
	void setUserDao(UserDao userDao);

	/**
	 * Retrieves a user by userId. An exception is thrown if user not found
	 * 
	 * @param userId
	 *            the identifier for the user
	 * @return User
	 */
	User getUser(String userId);

	/**
	 * Finds a user by their username.
	 * 
	 * @param username
	 *            the user's username used to login
	 * @return User a populated user object
	 */
	User getUserByUserName(String userName);

	/**
	 * Retrieves a list of users, filtering with parameters on a user object
	 * 
	 * @param user
	 *            parameters to filter on
	 * @return List
	 */
	List<User> getUsers(User user);

	/**
	 * Saves a user's information.
	 * 
	 * @param user
	 *            the user's information
	 * @throws UserExistsException
	 *             thrown when user already exists
	 * @return user the updated user object
	 */
	User saveUser(User user) throws UserExistsException;

	/**
	 * Removes a user from the database by their userId
	 * 
	 * @param userId
	 *            the user's id
	 */
	void removeUser(String userId);

	// �û���¼
	User login(String name, String password) throws XinYiException;
}
